package com.xboss.tv.bean;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;

import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/14.
 */

public class Contacts {

    public static boolean isLoad = false;
    public static boolean isEnter = false;

    public static final String caipu_url = "http://api.tianapi.com/txapi/caipu/";
    public static final String tiyu_url = "http://api.tianapi.com/tiyu/";
    public static final String keji_url = "http://api.tianapi.com/keji/";
    public static final String travel_url = "http://api.tianapi.com/travel/";

    public static final String tian_key = "f5ba679297658a67fc8f9a53b9fa6b41";

    //易源数据
    public static final String show_url = "http://route.showapi.com/109-35";
    //微信精选
    public static final String weixinjingxuan_url = "http://route.showapi.com/181-1";


    public static String show_appid = "41990";
    public static String show_secret = "1e681a0120f8481993ec872cdb8c4586";

    public static final String game_channelId = "5572a108b3cdc86cf39001d6";//游戏
    public static final String car_channelId = "5572a108b3cdc86cf39001d3";//汽车
    public static final String jiaoyu_channelId = "5572a10ab3cdc86cf39001ef";//教育
    public static final String caijing_channelId = "5572a109b3cdc86cf39001e0";//财经
    public static final String movie_channelId = "5572a10ab3cdc86cf39001ec";//电影
    public static final String house_channelId = "5572a109b3cdc86cf39001e4";//房产

    //京东万象
    public static final String jd_key = "73baaccb57708805ef078ed3296f34a9";
    public static final String jd_url = "https://way.jd.com/jisuapi/get";

    //阿里云数据
    public static final String ali_url = "http://toutiao-ali.juheapi.com/toutiao/index";
    public static String appcode = "33a03a0351af4e618f009101e42af7a5";
    //QQ音乐列表(阿里云)
    public static final String qqmusic_url = "https://ali-qqmusic.showapi.com/top";


    public static ProgressDialog progressDialog;

    public static void showProgress(Context context) {

        progressDialog = ProgressDialog.show(context, "请稍等...", "获取数据中...", true);
        progressDialog.show();
    }

    public static void hideProgress() {

        if (null != progressDialog) {
            progressDialog.dismiss();
            progressDialog = null;
        }
    }

    public static List<NewsBean> compatator(List<NewsBean> list) {

        Collections.sort(list, new Comparator<NewsBean>() {

            /*
             * int compare(Student o1, Student o2) 返回一个基本类型的整型，
             * 返回负数表示：o1 小于o2，
             * 返回0 表示：o1和o2相等，
             * 返回正数表示：o1大于o2。
             */
            public int compare(NewsBean o1, NewsBean o2) {

                //按照学生的年龄进行升序排列
                if (o1.showtime < o2.showtime) {
                    return 1;
                }
                if (o1.showtime == o2.showtime) {
                    return 0;
                }
                return -1;
            }
        });

        return list;
    }

    public static List<Activity> mActivitys = new LinkedList<Activity>();

    // add Activity
    public static void addActivity(Activity activity) {
        mActivitys.add(activity);
    }

    public static void removeActivitys() {

        for (Activity activity : mActivitys) {
            if (activity != null)
                activity.finish();
        }
    }
}
